package com.kgc.controller;

import com.kgc.document.Ticket;
import com.kgc.pojo.TicketInfoEx;
import com.kgc.service.TicketInfoService;
import com.kgc.service.TicketSolrService;
import com.kgc.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class TicketInfoController extends BaseController{
    @Autowired
    private TicketInfoService ticketInfoService;
    @Autowired
    private TicketSolrService ticketSolrService;//solr引擎的

    @RequestMapping("getTicketInfoByClassify_yuan")//通过点击分类获取商品
    public Object getTicketInfo(String content,Integer pageNow, Integer pageSize, Integer cityId, Integer perfomTypeId, Date startDate,Date endDate){
        Object ticketInfoList ;
        if(content!=null&&content!=""){
            String title=content;
          ticketInfoList=ticketSolrService.getTicketInfoList_CY(title,pageNow-1,pageSize);

        }else {
           System.out.println("startDate:" + startDate + ",,,,endDate:" + endDate);
           ticketInfoList = ticketInfoService.getTicketInfoByClassify(pageNow, pageSize, cityId, perfomTypeId, startDate, endDate);

       }
        return new Result(ticketInfoList,"获取商品成功");
    }


    @RequestMapping("getTicketInfoCount_yuan")
    public Object getTicketInfoCount_yuan(String content,Integer cityId, Integer perfomTypeId, Date startDate,Date endDate){
        int count=0;

        if(content!=null&&content!=""){

            count =ticketSolrService.getTicketInfoCount_CY(content);


        }else {

            count = ticketInfoService.getTicketInfoCount_yuan(cityId, perfomTypeId, startDate, endDate);
        }
            return new Result(count, "获取商品数量成功");

    }
}

